{% extends 'base.html' %}
{% block body %}

    <div class="fly-home fly-panel">
        <img src="{{ user_info.avatar.url }}" alt="{{ user_info.username }}">

        {% if user_info.renzheng %}
            <i class="iconfont icon-renzheng" title="社区认证"></i>
        {% endif %}
        <h1>
            {{ user_info.username }}
            {% if not user_info.sex or user_info.sex == 'male' %}
                <i class="iconfont icon-nan"></i>
            {% else %}
                <i class="iconfont icon-nv"></i>
            {% endif %}
            {% if user_info.vip > 0 %}
                <i class="layui-badge fly-badge-vip">VIP{{ user_info.vip }}</i>
            {% endif %}
            {% if user_info.is_superuser %}
                <span style="color:#c00">(管理员)</span>
            {% endif %}
            {% if not user_info.is_active %}
                <span style="color:#999">（该号已被封）</span>
            {% endif %}
        </h1>

        {% if user_info.renzheng %}
            <p style="padding: 10px 0; color: #5FB878;">认证信息：{{ user_info.renzheng }}</p>
        {% endif %}


        <p class="fly-home-info">
            <i class="iconfont icon-jifen" title="金币"></i><span style="color: #FF7200;">{{ user_info.coin|default:0 }} 金币</span>
            <i class="iconfont icon-shijian"></i><span>{{ user_info.date_joined|date:'Y-m-d H:i' }} 加入</span>
            <i class="iconfont icon-chengshi"></i><span>来自{{ user_info.city|default:'保密的火星' }}</span>
        </p>

        <p class="fly-home-sign">({{ user_info.desc|default:'这家伙懒得留下签名' }})</p>
    </div>
    <div class="layui-container">
        <div class="layui-row layui-col-space15">
            <div class="layui-col-md6 fly-home-jie">
                <div class="fly-panel">
                    <h3 class="fly-panel-title">{{ user_info.username }} 最近的帖子</h3>
                    <ul class="jie-row">
                        {% for item in posts %}
                            <li>
                                {% if item.is_cream %}
                                    <span class="fly-jing">精</span>
                                {% endif %}
                                <a href="{% url 'post_detail' item.pk %}" class="jie-title"> {{ item.title }}</a>
                                <i>{{ item.create_at|date:'Y-m-d H:i' }}</i>
                                <em class="layui-hide-xs">{{ item.view_count|default:0 }}阅/{{ item.comment_count|default:0 }}答</em>
                            </li>
                        {% empty %}
                            <div class="fly-none" style="min-height: 50px; padding:30px 0; height:auto;"><i
                                    style="font-size:14px;">没有发表任何帖子</i></div>
                        {% endfor %}

                    </ul>
                </div>
            </div>

            <div class="layui-col-md6 fly-home-da">
                <div class="fly-panel">
                    <h3 class="fly-panel-title">{{ user_info.username }} 最近的回帖</h3>
                    <ul class="home-jieda">
                        {% for item in comments %}
                            <li>
                                <p>
                                    <span>{{ item.create_at|date:'Y-m-d H:i' }}</span>
                                    在<a href="{% url 'post_detail' item.post.pk %}#item-{{ item.pk }}"
                                        target="_blank">{{ item.post.title|default:'(已删除)' }}</a>中回答：
                                </p>
                                <div class="home-dacontent">
                                    {{ item.content }}
                                </div>
                            </li>
                        {% empty %}
                            <div class="fly-none" style="min-height: 50px; padding:30px 0; height:auto;"><i
                                    style="font-size:14px;">没有发表任何回帖</i></div>
                        {% endfor %}

                    </ul>
                </div>
            </div>
        </div>
    </div>
{% endblock %}

{% block fly_use %}
    .use(['fly', 'face'], function(){
    var $ = layui.$
    ,fly = layui.fly;
    $('.home-dacontent').each(function(){
    var othis = $(this), html = othis.html();
    othis.html(fly.content(html));
    });
    });
{% endblock %}